

import java.io.DataInputStream;
import org.json.JSONArray;
import org.json.JSONObject;

public class GoogleSearch {
	
	public GoogleSearch(String text)throws Exception{
		framework obj=new framework();
		@SuppressWarnings("deprecation")
		String line= (new DataInputStream(obj.gsearch("https://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
			    + "q="+ text.replace(" ", "%20"))).readLine());
		getGooglelinks(line);
	}
	public void getGooglelinks(String line) throws Exception
    {
 	   JSONObject json = new JSONObject(line);
		JSONObject gson=json.getJSONObject("responseData");
		JSONArray kson=gson.getJSONArray("results");
		int size=kson.length();
		for(int i=0;i<size;i++)
		{
			JSONObject lson=kson.getJSONObject(i);
			String sample=lson.getString("url")	;		
			System.out.println(sample);
		}
    }
}
